package edu.nyp.locationservicesapp.activity;

import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import edu.nyp.locationservicesapp.R;
import edu.nyp.locationservicesapp.base.BaseActivity;
import edu.nyp.locationservicesapp.utils.ToastUtil;
import edu.nyp.locationservicesapp.utils.Util;

/**
 * 关于界面
 */
public class AboutUsActivity extends BaseActivity implements View.OnClickListener{
        @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_aboutus);
        initView();
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }

    protected void initView() {
        TextView tv_software_version = (TextView) findViewById(R.id.tv_software_version);
        PackageManager pm = getPackageManager();
        PackageInfo info;
        try {
            info = pm.getPackageInfo(getPackageName(), 0);
            tv_software_version.setText("V" + info.versionName);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ll_about_protocol:
                Intent intent = new Intent(this, AgreementActivity.class);
                startActivity(intent);
                overridePendingTransition(R.anim.activity_in_from_right, R.anim.activity_out_from_left);
                break;
            case R.id.ll_about_software_version:
                //点击版本更新
                if (!Util.isFastDoubleClickKeycodeBack(1000)) {
                    ToastUtil.showShortToast(this, getString(R.string.latest_version));
                }
                break;
        }
    }
}
